<?php


namespace app\admin\controller;
use think\Db;
use think\Request;
use think\Controller;
class Report extends ApiCommon
{
	/*
    分为三块来写，辅导员操作，高校老师操作，以及教育厅操作
	 */
	
	//---------------辅导员操作------------------
	//测试
	public function Text()
	{
		$newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->Text($param);
        return resultArray(['data'=> $data]);
	}

	//下拉列表
	public function DropdowmList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListDropdowm($param);
        return resultArray(['data'=> $data]);
    }

	//添加子项目
	 public function TrainWrite()
	 {
	    $newsModel = model('Report');
        $param=$this->param;
        $data=$newsModel->WriteTrain($param);
        if(!$data)
        {

            return resultArray(['error'=>$newsModel->getError()]);
        }
        return resultArray(['data'=>'添加成功']); 
	 }
	//修改子项目
	public function TrainRevise()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ReviseTrain($param);
        if(!$data)
        {
            return resultArray(['error'=>'修改数据失败']);
        }
        return resultArray(['data'=>'修改数据成功']);
    }
    //查看子项目详情列表
    public function ChildrenList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListChildren($param);
        return resultArray(['data'=> $data]);
    }
    //查看子项目的提交，中期审核，结题
    public function ReportList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListReport($param);
        return resultArray(['data'=> $data]);
    }
    //中期审核录入
   	public function MidWrite()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->WriteMid($param);
        if(!$data)
        {
            return resultArray(['error'=>'录入失败']);
        }
        return resultArray(['data'=>'录入成功']);
    }
    //中期审核详情
   	public function MidList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListMid($param);
        return resultArray(['data'=> $data]);
    }
    //结题录入
    public function EndWrite()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->WriteEnd($param);
        if(!$data)
        {
            return resultArray(['error'=>'录入失败']);
        }
        return resultArray(['data'=>'录入成功']);
    }
    //结题修改
    public function EndRevise()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ReviseEnd($param);
        if(!$data)
        {
            return resultArray(['error'=>'修改失败']);
        }
        return resultArray(['data'=>'修改成功']);
    }
    //结题详情
    public function EndList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListEnd($param);
        return resultArray(['data'=> $data]);
    }
    //结题一览表
    public function ProjectendList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListProjectend($param);
        return resultArray(['data'=> $data]);
    }

   //----------------教育厅---------------------
   


   //发布项目
   	public function EduWrite()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->WriteEdu($param);
        if(!$data)
        {
            return resultArray(['error'=>'发布项目失败']);
        }
        return resultArray(['data'=>'发布项目成功']);
    }
    //修改项目
        public function EduRevise()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ReviseEdu($param);
        if(!$data)
        {
            return resultArray(['error'=>'修改项目失败']);
        }
        return resultArray(['data'=>'修改项目成功']);
    }
    //删除项目
        public function EduDelete()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->DeleteEdu($param);
        if(!$data)
        {
            return resultArray(['error'=>'删除项目失败']);
        }
        return resultArray(['data'=>'删除项目成功']);
    }
    //查看项目
    public function EduList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListEdu($param);
        return resultArray(['data'=> $data]);
    }
    //查看专家
    public function ExpertList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListExpert($param);
        return resultArray(['data'=> $data]);
    }
    //所有分组
    public function GroupList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ListGroup($param);
        return resultArray(['data'=> $data]);
    }
    //结题所有分组
    public function endGroupList()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->endGroupList($param);
        return resultArray(['data'=> $data]);
    }
    //添加分组
   	public function GroupWrite()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->WriteGroup($param);
        if(!$data)
        {
            return resultArray(['error'=>'添加分组失败']);
        }
        return resultArray(['data'=>'添加分组成功']);
    }
    //结题添加分组
    public function endGroupWrite()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->endGroupWrite($param);
        if(!$data)
        {
            return resultArray(['error'=>'添加分组失败']);
        }
        return resultArray(['data'=>'添加分组成功']);
    }
     //修改分组
   	public function GroupRevise()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ReviseGroup($param);
        if(!$data)
        {
            return resultArray(['error'=>'修改分组失败']);
        }
        return resultArray(['data'=>'修改分组成功']);
    }
    //删除分组
        public function GroupDelete()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->DeleteGroup($param);
        if(!$data)
        {
            return resultArray(['error'=>'删除分组失败']);
        }
        return resultArray(['data'=>'删除分组成功']);
    }
    //教育厅导入专家
    public function ExpertImport()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ImportExpert($param);
        if(!$data)
        {
            return resultArray(['error'=>$newsModel->getError()]);
        }
        return resultArray(['data'=> $data]);
    }    
    //教育厅分配专家与材料
    public function EduDistribution()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->DistributionEdu($param);
        if(!$data)
        {
            return resultArray(['error'=>'分配失败']);
        }
        return resultArray(['data'=>'分配成功']);
    }
    //审核
    public function Check()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->Check($param);
        if(!$data)
        {
            return resultArray(['error'=>'审核失败']);
        }
        return resultArray(['data'=>'审核成功']);
    }
    //教育厅结束培训
    public function EduEnd()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->EndEdu($param);
        if(!$data)
        {
            return resultArray(['error'=>'结束失败']);
        }
        return resultArray(['data'=>'结束成功']);
    }


  //--------------专家--------------
  
    //专家评审列表
    public function ExpertReview()
    {
  	    $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ReviewExpert($param);
        return resultArray(['data'=> $data]);
    }
    //专家评审列表(结题)
    public function endExpertReview()
    {
      $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->endExpertReview($param);
        return resultArray(['data'=> $data]);
    }
    //专家评审
    public function ExpertWrite()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->WriteExpert($param);
        if(!$data)
        {
            return resultArray(['error'=>'评审失败']);
        }
        return resultArray(['data'=>'评审成功']);
    }
    //专家评审(结题)
    public function endExpertWrite()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->endExpertWrite($param);
        if(!$data)
        {
            return resultArray(['error'=>'评审失败']);
        }
        return resultArray(['data'=>'评审成功']);
    }
    //专家评审结果
    public function ExpertResult()
    {
        $newsModel=model('Report');
        $param=$this->param;
        $data=$newsModel->ResultExpert($param);
        return resultArray(['data'=> $data]);
    }
    // 获取指定大项目所有专家
    public function getAllExpert() 
    {
        $model = model('report');
        $param = $this->param;
        $data = $model->getAllExpert($param['project_id']);
        if (count($data) >= 0) {
        return resultArray(['data' => $data]);
        } else {
        return resultArray(['error' => $model->getError()]);
        }
    }
    // 获取指定大项目所有专家(结项)
    public function getEndAllExpert() 
    {
        $model = model('report');
        $param = $this->param;
        $data = $model->getEndAllExpert($param['project_id']);
        if (count($data) >= 0) {
        return resultArray(['data' => $data]);
        } else {
        return resultArray(['error' => $model->getError()]);
        }
    }
    // 获取指定大项目所有材料
    public function getAllMaterial() 
    {
        $model = model('report');
        $param = $this->param;
        $data = $model->getAllMaterial($param['project_id']);
        if (count($data) >= 0) {
        return resultArray(['data' => $data]);
        } else {
        return resultArray(['error' => $model->getError()]);
        }
    }
    // 获取指定大项目所有材料(结项)
    public function getEndAllMaterial() 
    {
        $model = model('report');
        $param = $this->param;
        $data = $model->getEndAllMaterial($param['project_id']);
        if (count($data) >= 0) {
        return resultArray(['data' => $data]);
        } else {
        return resultArray(['error' => $model->getError()]);
        }
    }
    // 专家和材料分组
    public function setExtAndMat() 
    {
        $model = model('report');
        $param = $this->param;
        $data = $model->setExtAndMat($param['group_id'], $param['experts'], $param['materials']);
        if ($data) {
            return resultArray(['data' => $data]);
        } else {
            return resultArray(['error' => $model->getError()]);
        }
    }   
    // 专家和材料分组(结题)
    public function setEndExtAndMat()
    {
        $model = model('report');
        $param = $this->param;
        $data = $model->setEndExtAndMat($param['group_id'], $param['experts'], $param['materials']);
        if ($data) {
            return resultArray(['data' => $data]);
        } else {
            return resultArray(['error' => $model->getError()]);
        }
    }  
}